{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "332126f9-3524-4223-bcc6-24b9818b77b5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from mythic import mythic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abfa531f-5e7a-400b-910c-92a62106ccbe",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "mythic_instance = await mythic.login(\n",
    "        username=\"mythic_admin\",\n",
    "        password=\"mythic_password\",\n",
    "        server_ip=\"mythic_nginx\",\n",
    "        server_port=7443,\n",
    "        timeout=-1\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa3c9e18-12b3-4b88-9157-c1b920fc64c7",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Creating Payloads ################\n",
    "payload_response = await mythic.create_payload(\n",
    "        mythic=mythic_instance,\n",
    "        payload_type_name=\"poseidon\",\n",
    "        filename=\"test.bin\",\n",
    "        operating_system=\"macOS\",\n",
    "        commands=[],\n",
    "        c2_profiles=[\n",
    "            {\n",
    "                \"c2_profile\": \"http\",\n",
    "                \"c2_profile_parameters\": {\n",
    "                    \"callback_host\": \"http://192.168.53.139\",\n",
    "                    \"callback_port\": \"80\",\n",
    "                },\n",
    "            }\n",
    "        ],\n",
    "        build_parameters=[{\"name\": \"mode\", \"value\": \"default\"}, {\"name\": \"garble\", \"value\": False}],\n",
    "        return_on_complete=False,\n",
    "    )\n",
    "print(payload_response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fe6758cd-ad55-47eb-869a-f555f1f11c73",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ############### Download a Payload ############\n",
    "payload_bytes = await mythic.download_payload(\n",
    "    mythic=mythic_instance, payload_uuid=payload_response[\"uuid\"]\n",
    ")\n",
    "print(payload_bytes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d3990a4-cdfb-4adc-8ffa-575afcf0be81",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Get all payloads ################\n",
    "payloads = await mythic.get_all_payloads(mythic=mythic_instance)\n",
    "print(payloads)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4758bf22-f5eb-4688-ae24-13f0290e0144",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Get all commands for a payload type ################\n",
    "resp = await mythic.get_all_commands_for_payloadtype(mythic=mythic_instance, payload_type_name=\"poseidon\")\n",
    "print(resp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5d831b8-5156-402c-b22a-5208b6dbb9f4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
